package com.goodving.guli.view;

import android.text.TextUtils;

import java.util.Calendar;

/**
 * Created by john on 2015/11/23.
 */
public class MiliConfig {
    public static final String BLUE = "BLUE";
    public static final String GREEN = "GREEN";
    public static final String LEFT_HAND = "LEFT_HAND";
    public static final String ONBODY = "ONBODY";
    public static final String ORANGE = "ORANGE";
    public static final String RED = "RED";
    public static final String RIGHT_HAND = "RIGHT_HAND";
    private static final String TAG = "MiliConfig";
    public boolean alarmNotifyEnabled;
    public String dayReportNoti;
    public int disconnectedReminder;
    public boolean enableConnectedBtAdv;
    public Calendar firstUseDate;
    public int goalStepsCount;
    public boolean hasHeartRate;
    public int inComingCallNotifyTime;
    public boolean incallContactNotifyEnabled;
    public boolean incallNotifyEnabled;
    public String lightColor;
    public boolean mOpenSleepNotify;
    public boolean sleepAssist;
    public boolean smsContactNotifyEnabled;
    public boolean smsNotifyEnabled;
    public int unit;
    public boolean vibrate;
    public String wearHand;
    private boolean weightMergeResult;
    public int weightUnit;

    public MiliConfig() {
        this.lightColor = BLUE;
        this.wearHand = LEFT_HAND;
        this.goalStepsCount = C4220a.bS;
//        this.dayReportNoti = C0668a.fH;
//        this.inComingCallNotifyTime = PersonInfo.INCOMING_CALL_DEFAULT;
        this.disconnectedReminder = 0;
        this.unit = 0;
        this.vibrate = false;
        this.sleepAssist = false;
        this.hasHeartRate = false;
        this.enableConnectedBtAdv = false;
        this.alarmNotifyEnabled = false;
        this.smsNotifyEnabled = false;
        this.smsContactNotifyEnabled = false;
        this.incallNotifyEnabled = false;
        this.incallContactNotifyEnabled = false;
        this.weightUnit = 0;
        this.weightMergeResult = false;
        this.mOpenSleepNotify = false;
    }

//    private static String formatJsonStr(String str) {
//        C2589z c2589z = new C2589z();
//        try {
//            JSONObject jSONObject = new JSONObject(str);
//            c2589z.m19620a("alarmNotifyEnabled", Boolean.valueOf(jSONObject.getString("alarmNotifyEnabled")));
//            c2589z.m19623a("dayReportNoti", jSONObject.getString("dayReportNoti"));
//            try {
//                c2589z.m19622a("disconnectedReminder", Integer.valueOf(jSONObject.getString("disconnectedReminder")));
//            } catch (Exception e) {
//                c2589z.m19622a("disconnectedReminder", Byte.valueOf((byte) 0));
//            }
//            c2589z.m19620a("enableConnectedBtAdv", Boolean.valueOf(jSONObject.getBoolean("enableConnectedBtAdv")));
//            c2589z.m19622a("goalStepsCount", Integer.valueOf(jSONObject.getInt("goalStepsCount")));
//            c2589z.m19623a("lightColor", jSONObject.getString("lightColor"));
//            c2589z.m19622a("inComingCallNotifyTime", Integer.valueOf(jSONObject.getInt("inComingCallNotifyTime")));
//            c2589z.m19620a("mOpenSleepNotify", Boolean.valueOf(jSONObject.getBoolean("mOpenSleepNotify")));
//            c2589z.m19620a("smsNotifyEnabled", Boolean.valueOf(jSONObject.getBoolean("smsNotifyEnabled")));
//            c2589z.m19620a("incallNotifyEnabled", Boolean.valueOf(jSONObject.getBoolean("incallNotifyEnabled")));
//            c2589z.m19622a("unit", Integer.valueOf(jSONObject.getInt("unit")));
//            c2589z.m19620a(AlarmActivity.f8764i, Boolean.valueOf(jSONObject.getBoolean(AlarmActivity.f8764i)));
//            c2589z.m19623a("wearHand", jSONObject.getString("wearHand"));
//            c2589z.m19620a("weightMergeResult", Boolean.valueOf(jSONObject.getBoolean("weightMergeResult")));
//            c2589z.m19622a("weightUnit", Integer.valueOf(jSONObject.getInt("weightUnit")));
//            c2589z.m19620a("smsContactNotifyEnabled", Boolean.valueOf(jSONObject.getBoolean("smsContactNotifyEnabled")));
//            c2589z.m19620a("incallContactNotifyEnabled", Boolean.valueOf(jSONObject.getBoolean("incallContactNotifyEnabled")));
//            c2589z.m19620a("sleepAssist", Boolean.valueOf(jSONObject.optBoolean("sleepAssist")));
//            c2589z.m19620a("hasHeartRate", Boolean.valueOf(jSONObject.optBoolean("hasHeartRate")));
//            return c2589z.toString();
//        } catch (JSONException e2) {
//            e2.printStackTrace();
//            return str;
//        }
//    }

//    public static MiliConfig fromJsonStr(String str) {
//        MiliConfig miliConfig;
//        GuliLog.tracePrintInfo("SCORPIONEAL", "the MiliConfig fromString is " + str);
//        try {
//            miliConfig = (MiliConfig) Utils.m8049c().fromJson(str, MiliConfig.class);
//        } catch (Exception e) {
//            try {
//                miliConfig = (MiliConfig) Utils.m8049c().fromJson(formatJsonStr(str), MiliConfig.class);
//            } catch (Exception e2) {
//                miliConfig = new MiliConfig();
//            }
//        }
//        return miliConfig == null ? new MiliConfig() : miliConfig;
//    }

    public boolean getDailySleepNofity() {
        return this.mOpenSleepNotify;
    }

    public String getDailySportNofity() {
        return this.dayReportNoti;
    }

    public boolean getWeightMergeResult() {
        return this.weightMergeResult;
    }

    public boolean isValid() {
        boolean z = !TextUtils.isEmpty(this.lightColor) && !TextUtils.isEmpty(this.wearHand) && this.goalStepsCount > 0 && (this.inComingCallNotifyTime == -1 || this.inComingCallNotifyTime >= 0);
//        GuliLog.tracePrintInfo(TAG, "isValid=" + z + ", " + this);
        return z;
    }

    public void setDailySleepNotify(boolean z) {
        this.mOpenSleepNotify = z;
    }

    public void setDailySportNotify(String str) {
        this.dayReportNoti = str;
    }

    public void setWeightMergeResult(boolean z) {
        this.weightMergeResult = z;
    }
//
//    public String toString() {
//        String b = Utils.m8049c().toJson((Object) this);
//        if (b == null) {
//            return null;
//        }
//        GuliLog.tracePrintInfo("SCORPIONEAL", "the MiliConfig ---toString--- is " + b.toString());
//        return b.toString();
//    }
}

